package net.homelinux.chaoswg.io.renga.core.registries;

import java.util.HashMap;
import java.util.Map;

import net.homelinux.chaoswg.io.datatypes.Pair;
import net.homelinux.chaoswg.io.renga.core.converter.Converter;

public class ConverterRegistry {
    private static Map<Pair<Class, Class>, Converter>_registry;
    private static ConverterRegistry cr = null;
    
    private ConverterRegistry () {
        _registry = new HashMap<Pair<Class,Class>, Converter> ();
    }
    
    public final static ConverterRegistry getConverterRegistry () {
        if (cr == null) {
            cr = new ConverterRegistry();
        }
        return cr;
    }
    
    public Converter getConverter (final Pair<Class, Class> types) {
        return _registry.get(types);
    }
    
    public void setConverter (final Pair<Class, Class> types, final Converter converter) {
        _registry.put(types, converter);
    }
}
